package com.su.kddq.config;


import com.aliyun.teaopenapi.models.Config;
import com.su.kddq.constant.OssConst;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author sx
 * Mq 消息转换器配置
 */
@Configuration
public class MqMessageConverterConfig {


    @Autowired
    private OssConst ossConst;

    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }


    /**
     * 阿里云短信发送配置
     *
     * @return
     * @throws Exception
     */
    @Bean
    public com.aliyun.dysmsapi20170525.Client createClient() throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(ossConst.getKEYID())
                // 您的AccessKey Secret
                .setAccessKeySecret(ossConst.getKEYSECERT());
        // 访问的域名
        config.endpoint = "dysmsapi.aliyuncs.com";
        return new com.aliyun.dysmsapi20170525.Client(config);
    }

}
